package com.cloud.dto;

import com.cloud.enums.ResultEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @program: zry
 * @description: ${description}
 * @author: LiuChao
 * @create: 2018-04-18 11:40
 **/
@Getter
@Setter
@ApiModel(value = "响应对象")
public class ResponseDto<T> {

    @ApiModelProperty(value = "状态码")
    private int code;

    @ApiModelProperty(value = "消息")
    private String msg;

    @ApiModelProperty(value = "数据")
    private T data;

    public ResponseDto() {}
    
    public ResponseDto(ResultEnum resultEnum, T data) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMessage();
        this.data = data;
    }
    
    public static ResponseDto successWithData(Object data){
        return new ResponseDto(ResultEnum.success,data);
    }


}
